 var a=localStorage.getItem("userNum")
 /*
          渲染列表
        */
        var vm = new Vue({
           el: '#app',
           data() {
               /* id:''
               name:''
               length:''
                 */

               return {
                   list: [],
                   offOn: ''

               }
           },
           beforeCreate: function () {
           var _this = this
            $.ajax({
                type: "post",//请求方式
                url: "http://39.108.233.68:8002/student/selAllTeachCourseWithStuId",
                data: { id: a },
                success: function (data) {
                    //_this.list = data.data
                    for (var i = 0; i < data.data.length; i++) {
                        if (data.data[i].course != null) {
                            _this.list.push(data.data[i])
                        }
                    }
                   
                   // console.log(_this.list)
                    $.ajax({
                        type: "get",//请求方式
                        //async: true,
                        url: "http://39.108.233.68:8002/onOff/checkCourseOnOff",
                        success: function (data) {
                            if (data.data[0].stuSelecter == '1') {
                                _this.offOn = '当前处于选课状态，可以选课'

                            } else {
                                _this.offOn = '当前选课开关关闭，你无法选课'
                            }

                        },
                        error: function () {
                            alert("error");
                        }
                    })
                    
                },
                error: function () {
                    alert("error");
                }
                
            })

        },
           updated: function () {
               $('#dataList').DataTable({

                   language: {
                       "sProcessing": "处理中...",
                       "sLengthMenu": "显示 _MENU_ 项结果",
                       "sZeroRecords": "没有匹配结果",
                       "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                       "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                       "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                       "sInfoPostFix": "",
                       "sSearch": "搜索:",
                       "sUrl": "",
                       "sEmptyTable": "表中数据为空",
                       "sLoadingRecords": "载入中...",
                       "sInfoThousands": ",",
                       "oPaginate": {
                           "sFirst": "首页",
                           "sPrevious": "上页",
                           "sNext": "下页",
                           "sLast": "末页"
                       },

                   },
                   "paging": true,
                   "lengthChange": false,
                   "searching": false,
                   "ordering": false,
                   "info": true,
                   "autoWidth": false,
                   "destroy":true,
               });

           },
           methods: {

               toChoose: function (id) {
                   
                  console.log(id)
                  $.ajax({
                    type: "post",
                    url: 'http://39.108.233.68:8002/onOff/checkCourseOnOff',//先看开关开没开
                    //data: { userNum: localStorage.getItem("userNum"), password: old_passwd },
                    success: function (data) {
                        if (data.data[0].stuSelecter == '1') {
                            $.ajax({
                                type: 'post',
                                url: 'http://39.108.233.68:8002/student/insOneSelectCourse',
                                data: {
                                    stuId: a,
                                    tecId:id,
                                },
                                success: function (data) {
                                    //console.log(data)

                                    window.location.reload();
                                    alert("选课成功！");
                                },
                                error: function (data) {
                                    window.location.reload();
                                    alert("选课冲突或无法选课！");

                                }
                            });
                        } else {
                            window.location.reload();
                            alert("选课开关未开，当前不处于选课状态！");

                        }
                    },
                    error: function () {
                        alert("系统状态异常");
                    }
                })
               
                   
               },


               
           },

           mounted: function () {
               this.queryData();
           }
       });